﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace 完全自定义命令
{
    /// <summary>
    /// 自定义命令
    /// </summary>
    public class CustCmd : ICommand
    {
        // 1、能否执行  2、如何执行

        #region 实现接口

        /// <summary>
        /// 命令状态发生改变的事件
        /// </summary>
        public event EventHandler CanExecuteChanged;

        /// <summary>
        /// 能否执行 (命令状态)
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public bool CanExecute(object parameter)
        {
            if (parameter == null)
            {
                return false;
            }
            return true;
            // throw new NotImplementedException();
        }

        /// <summary>
        /// 如何执行 (执行业务)
        /// </summary>
        /// <param name="parameter"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void Execute(object parameter)
        {
            MessageBox.Show("状态：[执行业务] \n" + parameter);
            // throw new NotImplementedException();
        }

        #endregion
    }
}
